<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>模板字符串</title>
</head>
<body>
<div class="box1"></div>
<script type="text/javascript">
    window.onload = () => {
        const box1 = document.querySelector('.box1');
        let id = 1,name = 'tom';
        box1.innerHTML = `
            <ul>
                <li>
                    <span id=${id}>${name}</span>
                </li>
            </ul>
        `;
    }
</script>
</body>
</html>